package com.banban.user.service.impl;

import com.banban.user.domain.UserPrologue;
import com.banban.user.dto.SavePrologueDTO;
import com.banban.user.mapper.UserPrologueMapper;
import com.banban.user.service.UserPrologueService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserPrologueServiceImpl extends ServiceImpl<UserPrologueMapper, UserPrologue>  implements UserPrologueService {

    @Resource
    private UserPrologueMapper userPrologueMapper;

    @Override
    public String getPrologue() {
        UserPrologue userPrologue = userPrologueMapper.selectById(1);
        if (userPrologue != null) {
            return userPrologue.getPrologue();
        }
        return "";
    }

    @Override
    public void setPrologue(SavePrologueDTO dto) {
        UserPrologue userPrologue = new UserPrologue();
        userPrologue.setId(1L);
        userPrologue.setPrologue(dto.getPrologue());
        updateById(userPrologue);
    }
}
